package org.acme.oauth2.client;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * @author LiJian
 * @date 2021/6/21 15:52
 */

@Singleton
@RegisterRestClient(configKey = "AuthorizationUrl")
@RegisterClientHeaders
public interface Oauth2AuthorizationService {


    @GET
    @Path("/oauth/authorize")
    @Produces(MediaType.APPLICATION_JSON)
    Response getCodeByAuthorization(@QueryParam("client_id") String clientId,
                                @QueryParam("response_type") String response_type,
                                @QueryParam("scope") String scope,
                                @QueryParam("state") String state,
                                @QueryParam("redirect_uri") String redirect_uri
    );
    @POST
    @Path("/oauth/token")
    @Produces(MediaType.APPLICATION_JSON)
    Response getTokenByAuthorization(@QueryParam("code") String code,
                                     @QueryParam("grant_type") String grant_type,
                                     @QueryParam("redirect_uri") String redirect_uri
    );
}
